; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -O0 -mtriple=x86_64-unknown-unknown < %s | FileCheck %s

; ModuleID = 'variadic.c'
source_filename = "variadic.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux"

%struct.__va_list_tag = type { i32, i32, ptr, ptr }

@.str = private unnamed_addr constant [9 x i8] c"\0A hello \00", align 1

; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @testvarargs(ptr %fmt, ...) {
; CHECK-LABEL: testvarargs:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    subq $216, %rsp
; CHECK-NEXT:    .cfi_def_cfa_offset 224
; CHECK-NEXT:    testb %al, %al
; CHECK-NEXT:    je .LBB0_2
; CHECK-NEXT:  # %bb.1: # %entry
; CHECK-NEXT:    movaps %xmm0, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movaps %xmm1, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movaps %xmm2, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movaps %xmm3, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movaps %xmm4, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movaps %xmm5, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movaps %xmm6, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movaps %xmm7, {{[0-9]+}}(%rsp)
; CHECK-NEXT:  .LBB0_2: # %entry
; CHECK-NEXT:    movq %r9, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movq %r8, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movq %rcx, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movq %rdx, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movq %rsi, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movq %rdi, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movq %rsp, %rax
; CHECK-NEXT:    movq %rax, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    leaq {{[0-9]+}}(%rsp), %rax
; CHECK-NEXT:    movq %rax, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movl $48, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movl $8, {{[0-9]+}}(%rsp)
; CHECK-NEXT:    movl $.L.str, %edi
; CHECK-NEXT:    xorl %eax, %eax
; CHECK-NEXT:    # kill: def $al killed $al killed $eax
; CHECK-NEXT:    callq printf
; CHECK-NEXT:    addq $216, %rsp
; CHECK-NEXT:    .cfi_def_cfa_offset 8
; CHECK-NEXT:    retq
entry:
  %fmt.addr = alloca ptr, align 8
  %va = alloca [1 x %struct.__va_list_tag], align 16
  store ptr %fmt, ptr %fmt.addr, align 8
  call void @llvm.va_start(ptr %va)
  call void @llvm.va_end(ptr %va)
  %call = call i32 (ptr, ...) @printf(ptr @.str)
  ret void
}

; Function Attrs: nounwind
declare void @llvm.va_start(ptr)

; Function Attrs: nounwind
declare void @llvm.va_end(ptr)

declare dso_local i32 @printf(ptr, ...)
